<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?>
    	<?php if(isset($breadcrumb['href']) && $breadcrumb['href'] != '' && $breadcrumb['href'] != '#') {?>
	    	<a href="<?php echo $breadcrumb['href']; ?>">
	    		<?php echo $breadcrumb['text']; ?>
	    	</a>
    	<?php }else{?>
    		<?php echo $breadcrumb['text']; ?>
    	<?php }?>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/setting.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a></div>
    </div>
    <div class="content">
      <div id="tabs" class="htabs">
      	<a href="#tab-general"><?php echo $tab_general; ?></a>
      	<a href="#tab-restaurant"><?php echo $tab_restaurant; ?></a>
      	<a href="#tab-restaurant-option"><?php echo $tab_restaurant_option; ?></a>
      	<a href="#tab-template"><?php echo $tab_template; ?></a>
      	<a href="#tab-local"><?php echo $tab_local; ?></a>
      	<a href="#tab-option"><?php echo $tab_option; ?></a>
      	<a href="#tab-image"><?php echo $tab_image; ?></a>
      </div>
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
        <div id="tab-general">
          <div id="languages" class="htabs">
            <?php foreach ($languages as $language) { 
            	if(!$language['portal']) {
            		continue;
            	}
            ?>
            <a href="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
            <?php } ?>
          </div>
          <?php foreach ($languages as $language) {
            if(!$language['portal']) {
            	continue;
            }
          ?>
          <div id="language<?php echo $language['language_id']; ?>">
	        <table class="form">
              <tr>
                <td><span class="required">*</span> <?php echo $entry_name; ?></td>
                <td><input type="text" name="description[<?php echo $language['language_id']; ?>][name]" size="100" value="<?php echo isset($description[$language['language_id']]) ? $description[$language['language_id']]['name'] : ''; ?>" />
                  <?php if (isset($error_name[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_name[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>
              <tr>
                <td><?php echo $entry_meta_description; ?></td>
                <td><textarea name="description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo isset($description[$language['language_id']]) ? $description[$language['language_id']]['meta_description'] : ''; ?></textarea></td>
              </tr>
              <tr>
                <td><?php echo $entry_meta_keyword; ?></td>
                <td><textarea name="description[<?php echo $language['language_id']; ?>][meta_keyword]" cols="40" rows="5"><?php echo isset($description[$language['language_id']]) ? $description[$language['language_id']]['meta_keyword'] : ''; ?></textarea></td>
              </tr>
              <tr>
                <td><?php echo $entry_description; ?></td>
                <td><textarea name="description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($description[$language['language_id']]) ? $description[$language['language_id']]['description'] : ''; ?></textarea></td>
              </tr>
              <tr>
                <td><?php echo $entry_tag; ?></td>
                <td><input type="text" name="restaurant_tag[<?php echo $language['language_id']; ?>]" value="<?php echo isset($restaurant_tag[$language['language_id']]) ? $restaurant_tag[$language['language_id']] : ''; ?>" size="80" /></td>
              </tr>
            </table>
	      </div>
          <?php } ?>
        </div>
        <div id="tab-restaurant">
          <table class="form">
          	<tr>
              <td><span class="required">*</span> <?php echo $entry_url; ?></td>
              <td><input type="text" name="config_url" value="<?php echo $config_url; ?>" size="40" />
                <?php if ($error_url) { ?>
                <span class="error"><?php echo $error_url; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><?php echo $entry_ssl; ?></td>
              <td><input type="text" name="config_ssl" value="<?php echo $config_ssl; ?>" size="40" /></td>
            </tr>
            <tr>
              <td><?php echo $entry_keyword; ?></td>
              <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_owner; ?></td>
              <td><input type="text" name="config_owner" value="<?php echo $config_owner; ?>" size="40" />
                <?php if ($error_owner) { ?>
                <span class="error"><?php echo $error_owner; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_email; ?></td>
              <td><input type="text" name="config_email" value="<?php echo $config_email; ?>" size="40" />
                <?php if ($error_email) { ?>
                <span class="error"><?php echo $error_email; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
              <td><input type="text" name="config_telephone" value="<?php echo $config_telephone; ?>" />
                <?php if ($error_telephone) { ?>
                <span class="error"><?php echo $error_telephone; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><?php echo $entry_fax; ?></td>
              <td><input type="text" name="config_fax" value="<?php echo $config_fax; ?>" /></td>
            </tr>
          </table>
        </div>
        <div id="tab-restaurant-option">
          <table class="form">
          	<?php foreach ($options as $option) { ?>
            <tr>
              <td><b><?php echo $option['name']; ?>:</b><br/><br/>
              	<input type="hidden" name="restaurant_option[<?php echo $option['option_id']; ?>][option_id]" value="<?php echo $option['option_id']; ?>" />
              	<input type="hidden" name="restaurant_option[<?php echo $option['option_id']; ?>][type]" value="<?php echo $option['type']; ?>" />
              	<?php if($option['type'] === 'checkbox'){?>
	              	<div class="option">
		              	<div id="container" style="overflow:hidden">
		              		<div id="inner" style="overflow:hidden;width: 100%">
						          <?php foreach ($option['values'] as $option_value) { ?>
				              		  <div style="float:left;width:180px;height:50px">
								          <?php 
								          $checked = "";
								          if(isset($restaurant_option[$option['option_id']]) && isset($restaurant_option[$option['option_id']]['restaurant_option_value'])) {
									          if(!is_array($restaurant_option[$option['option_id']]['restaurant_option_value']) && 
									          		$option_value['option_value_id'] == $restaurant_option[$option['option_id']]['restaurant_option_value']){
									          	$checked = "checked";
									          } else if(isset($restaurant_option[$option['option_id']]['restaurant_option_value']) &&
									          		in_array($option_value['option_value_id'], $restaurant_option[$option['option_id']]['restaurant_option_value'])) {
									          	$checked = "checked";
									          }
								          }
								          ?>
								          <input <?php echo $checked;?> type="checkbox" name="restaurant_option[<?php echo $option['option_id']; ?>][restaurant_option_value][]" value="<?php echo $option_value['option_value_id']; ?>" id="option-value-<?php echo $option_value['option_value_id']; ?>" />
								          <label for="option-value-<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
								          </label>
							          </div>
						          <?php } ?>
						    </div>
						</div>
					</div>
		        <?php }?>
              	<?php if($option['type'] === 'radio'){?>
	              	<div class="option">
			          <?php foreach ($option['values'] as $option_value) { ?>
				          <?php 
				          $checked = "";
				          if(isset($restaurant_option[$option['option_id']]) && isset($restaurant_option[$option['option_id']]['restaurant_option_value'])) {
					          if(isset($restaurant_option[$option['option_id']]) &&
					            in_array($option_value['option_value_id'], $restaurant_option[$option['option_id']]['restaurant_option_value'])) {
					          	$checked = "checked";
					          }
				          }
				          ?>
				          <input <?php echo $checked;?> type="radio" name="restaurant_option[<?php echo $option['option_id']; ?>][restaurant_option_value][]" value="<?php echo $option_value['option_value_id']; ?>" id="option-value-<?php echo $option_value['option_value_id']; ?>" />
				          <label for="option-value-<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
				          </label>
				          &nbsp;&nbsp;
			          <?php } ?>
			        </div>
			        <br />
		        <?php }?>
		        
		        <?php if($option['type'] === 'select'){?>
	              	<div class="option">
	              	  <select name="restaurant_option[<?php echo $option['option_id']; ?>][restaurant_option_value][]">
			            <option value=""><?php echo $text_select; ?></option>
			            <?php foreach ($option['values'] as $option_value) { ?>
				            <?php 
				            $selected = "";
        	            	if(isset($restaurant_option[$option['option_id']])) {
						          if(!is_array($restaurant_option[$option['option_id']]['restaurant_option_value']) && 
						          		$option_value['option_value_id'] == $restaurant_option[$option['option_id']]['restaurant_option_value']){
						          	$selected = "selected";
						          } else if(isset($restaurant_option[$option['option_id']]['restaurant_option_value']) &&
						          		in_array($option_value['option_value_id'], $restaurant_option[$option['option_id']]['restaurant_option_value'])) {
						          	$selected = "selected";
						          }
					        }
				            
					        ?>
				            <option <?php echo $selected;?> value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
				            </option>
			            <?php } ?>
			          </select>
			        </div>
			        <br />
		        <?php }?>
		        
		        <?php if ($option['type'] == 'image') { ?>
			        <div class="option">
			        	<div id="container" style="overflow:hidden">
				        	<div id="inner" style="overflow:hidden;width: 100%">
					            <?php foreach ($option['values'] as $option_value) { ?>
				        			<div style="float:left;width:180px;height:50px">
							            <table class="option-image">
							              <?php 
					            		  $checked = "";
					            		  if(isset($restaurant_option[$option['option_id']]) && isset($restaurant_option[$option['option_id']]['restaurant_option_value'])) {
									          if(!is_array($restaurant_option[$option['option_id']]['restaurant_option_value']) && 
									          		$option_value['option_value_id'] == $restaurant_option[$option['option_id']]['restaurant_option_value']){
									          	$checked = "checked";
									          } else if(isset($restaurant_option[$option['option_id']]['restaurant_option_value']) &&
									          		in_array($option_value['option_value_id'], $restaurant_option[$option['option_id']]['restaurant_option_value'])) {
									          	$checked = "checked";
									          }
								          }
								          ?>
							              <tr>
							                <td style="width: 1px;">
							                	<input <?php echo $checked;?> type="checkbox" name="restaurant_option[<?php echo $option['option_id'];?>][restaurant_option_value][]" value="<?php echo $option_value['option_value_id']; ?>" id="option-value-<?php echo $option_value['option_value_id']; ?>" />
							                </td>
							                <td><label for="option-value-<?php echo $option_value['option_value_id']; ?>"><img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name']; ?>" /></label></td>
							                <td><label for="option-value-<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
							                  </label></td>
							              </tr>
							            </table>
						            </div>
				                <?php } ?>
				            </div>
				         </div>
			        </div>
			        <br/>
		        <?php } ?>
              </td>
            </tr>
            <?php }?>
          </table>
        </div>
        <div id="tab-template">
          <table class="form">
            <tr>
              <td><span class="required">*</span> <?php echo $entry_title; ?></td>
              <td><input size="40" type="text" name="config_title" value="<?php echo $config_title; ?>" />
                <?php if ($error_title) { ?>
                <span class="error"><?php echo $error_title; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><?php echo $entry_template; ?></td>
              <td><select name="config_template" onchange="$('#template').load('index.php?route=restaurant/autocomplete/template&token=<?php echo $token; ?>&template_id=' + encodeURIComponent(this.value));">
                  <?php foreach ($templates as $template) { ?>
                  <?php if ($template['template_id'] == $config_template) { ?>
                  <option value="<?php echo $template['template_id']; ?>" selected="selected"><?php echo $template['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $template['template_id']; ?>"><?php echo $template['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
            <tr>
              <td></td>
              <td id="template"></td>
            </tr>
            <tr style="display:none">
              <td><?php echo $entry_layout; ?></td>
              <td><select name="config_layout_id">
                  <?php foreach ($layouts as $layout) { ?>
                  <?php if ($layout['layout_id'] == $config_layout_id) { ?>
                  <option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
          </table>
        </div>
        <div id="tab-local">
			<table id="addresses" class="list">
				<thead>
					<tr>
						<td style="width:150px"><?php echo $entry_country; ?></td>
						<td style="width:200px"><?php echo $entry_city; ?></td>
						<td style="width:200px"><span class="required">*</span> <?php echo $entry_district; ?></td>
						<td><span class="required">*</span> <?php echo $entry_address; ?></td>
						<td style="width:120px"></td>
					</tr>
				</thead>
				<tbody>
					<?php $address_row = 0; ?>
					<?php foreach ($addresses as $address){?>
					<tr id="address-row<?php echo $address_row; ?>">
						<td>
							<select name="addresses[<?php echo $address_row;?>][country_id]" id="country_id<?php echo $address_row;?>" onchange="$('city_id<?php echo $address_row;?>').load('index.php?route=restaurant/autocomplete/city&token=<?php echo $token; ?>&country_id=' + this.value + '&city_id=<?php echo $address['city_id']; ?>');">
			                  <?php foreach ($countries as $country) { ?>
			                  <?php if ($country['country_id'] == $address['country_id']) { ?>
			                  <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
			                  <?php } else { ?>
			                  <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
			                  <?php } ?>
			                  <?php } ?>
			                </select>
						</td>
						<td>
							<select name="addresses[<?php echo $address_row;?>][city_id]" id="city_id<?php echo $address_row;?>" onchange="$('#district_id<?php echo $address_row;?>').load('index.php?route=restaurant/autocomplete/district&token=<?php echo $token; ?>&city_id=' + this.value + '&district_id=<?php echo $address['district_id']; ?>');">
                			</select>
						</td>
						<td>
							<select name="addresses[<?php echo $address_row;?>][district_id]" id="district_id<?php echo $address_row;?>">
			                </select>
			                <?php if (isset($error_district[$address_row])) { ?>
			                <span class="error"><?php echo $error_district[$address_row]; ?></span>
			                <?php } ?>
						</td>
						<td>
							<textarea name="addresses[<?php echo $address_row;?>][address]" id="address<?php echo $address_row;?>" cols="60" rows="5"><?php echo $address['address']; ?></textarea>
			                <?php if (isset($error_address[$address_row])) { ?>
			                <span class="error"><?php echo $error_address[$address_row]; ?></span>
			                <?php } ?>
						</td>
						<td class="center">
							<a onclick="$('#address-row<?php echo $address_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a>
							
							<script type="text/javascript"><!--
							// Load default citys
							$('#city_id<?php echo $address_row;?>').load('index.php?route=restaurant/autocomplete/city&token=<?php echo $token; ?>&country_id=<?php echo $address['country_id']; ?>&city_id=<?php echo $address['city_id']; ?>');
							
							// Load default districts
							$('#district_id<?php echo $address_row;?>').load('index.php?route=restaurant/autocomplete/district&token=<?php echo $token; ?>&city_id=<?php echo $address['city_id']; ?>&district_id=<?php echo $address['district_id']; ?>');
							
							//--></script>							
						</td>
					</tr>
					<?php $address_row++; ?>
					<?php }?>
				</tbody>
	            <tfoot>
	              <tr>
	                <td colspan="4">
	                	<?php if (isset($error_require_address)) { ?>
		                <span class="error"><?php echo $error_require_address; ?></span>
		                <?php } ?>
	                </td>
	                <td class="center"><a onclick="addAddress();" class="button"><?php echo $button_add_address; ?></a></td>
	              </tr>
	            </tfoot>
			</table>
          
          
        </div>
        <div id="tab-option">
          <table class="form">
            <tr>
              <td style="width:40%"><?php echo $entry_languages; ?></td>
              <td>
                  <?php foreach ($languages as $language) { ?>
                  <?php if ($language['mandatory']) { ?>
	                  <input type="checkbox" value="<?php echo $language['code']; ?>" disabled="disabled" checked="checked" />
	                  <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> 
	                  <?php echo $language['name']; ?>
	                  <input type="hidden" value="<?php echo $language['code']; ?>" name="config_supported_language[<?php echo $language['code']; ?>]" />
                  <?php } else { ?>
	                  <?php if(isset($config_supported_language[$language['code']]) && $config_supported_language[$language['code']] == $language['code']){?>
		                  <input type="checkbox" value="<?php echo $language['code']; ?>" id="config_supported_language[<?php echo $language['code']; ?>]" name="config_supported_language[<?php echo $language['code']; ?>]" checked="checked" />
		                  <label for="config_supported_language[<?php echo $language['code']; ?>]">
			                <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> 
		                  	<?php echo $language['name']; ?>
		                  </label>
	                  <?php }else{?>
		                  <input type="checkbox" value="<?php echo $language['code']; ?>" id="config_supported_language[<?php echo $language['code']; ?>]" name="config_supported_language[<?php echo $language['code']; ?>]" />
		                  <label for="config_supported_language[<?php echo $language['code']; ?>]">
			                <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> 
		                  	<?php echo $language['name']; ?>
		                  </label>
	                  <?php }?>
                  <?php } ?>
                  <?php } ?>
               </td>
            </tr>
            <tr>
              <td><?php echo $entry_language; ?></td>
              <td><select name="language">
                  <?php foreach ($languages as $language) { ?>
                  <?php if ($language['code'] == $language) { ?>
                  <option value="<?php echo $language['code']; ?>" selected="selected"><?php echo $language['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $language['code']; ?>"><?php echo $language['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
            <tr>
              <td><?php echo $entry_currency; ?></td>
              <td><select name="currency">
                  <?php foreach ($currencies as $c) { ?>
                  <?php if ($c['code'] == $currency) { ?>
                  <option value="<?php echo $c['code']; ?>" selected="selected"><?php echo $c['title']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $c['code']; ?>"><?php echo $c['title']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
          </table>
          <table class="form">
            <tr>
              <td><?php echo $entry_invoice_prefix; ?></td>
              <td><input type="text" name="config_invoice_prefix" value="<?php echo $config_invoice_prefix; ?>" /></td>
            </tr>
            <tr>
              <td style="width:40%"><span class="required">*</span> <?php echo $entry_catalog_limit; ?></td>
              <td><input type="text" name="config_catalog_limit" value="<?php echo $config_catalog_limit; ?>" size="3" />
                <?php if ($error_catalog_limit) { ?>
                <span class="error"><?php echo $error_catalog_limit; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_logo; ?></td>
              <td><input type="text" name="config_image_logo_width" value="<?php echo $config_image_logo_width; ?>" size="3" />
                x
                <input type="text" name="config_image_logo_height" value="<?php echo $config_image_logo_height; ?>" size="3" />
                <?php if ($error_image_logo) { ?>
                <span class="error"><?php echo $error_image_logo; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_category; ?></td>
              <td><input type="text" name="config_image_category_width" value="<?php echo $config_image_category_width; ?>" size="3" />
                x
                <input type="text" name="config_image_category_height" value="<?php echo $config_image_category_height; ?>" size="3" />
                <?php if ($error_image_category) { ?>
                <span class="error"><?php echo $error_image_category; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_thumb; ?></td>
              <td><input type="text" name="config_image_thumb_width" value="<?php echo $config_image_thumb_width; ?>" size="3" />
                x
                <input type="text" name="config_image_thumb_height" value="<?php echo $config_image_thumb_height; ?>" size="3" />
                <?php if ($error_image_thumb) { ?>
                <span class="error"><?php echo $error_image_thumb; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_popup; ?></td>
              <td><input type="text" name="config_image_popup_width" value="<?php echo $config_image_popup_width; ?>" size="3" />
                x
                <input type="text" name="config_image_popup_height" value="<?php echo $config_image_popup_height; ?>" size="3" />
                <?php if ($error_image_popup) { ?>
                <span class="error"><?php echo $error_image_popup; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_food; ?></td>
              <td><input type="text" name="config_image_food_width" value="<?php echo $config_image_food_width; ?>" size="3" />
                x
                <input type="text" name="config_image_food_height" value="<?php echo $config_image_food_height; ?>" size="3" />
                <?php if ($error_image_food) { ?>
                <span class="error"><?php echo $error_image_food; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_additional; ?></td>
              <td><input type="text" name="config_image_additional_width" value="<?php echo $config_image_additional_width; ?>" size="3" />
                x
                <input type="text" name="config_image_additional_height" value="<?php echo $config_image_additional_height; ?>" size="3" />
                <?php if ($error_image_additional) { ?>
                <span class="error"><?php echo $error_image_additional; ?></span>
                <?php } ?></td>
            </tr>
            <tr>
              <td><span class="required">*</span> <?php echo $entry_image_related; ?></td>
              <td><input type="text" name="config_image_related_width" value="<?php echo $config_image_related_width; ?>" size="3" />
                x
                <input type="text" name="config_image_related_height" value="<?php echo $config_image_related_height; ?>" size="3" />
                <?php if ($error_image_related) { ?>
                <span class="error"><?php echo $error_image_related; ?></span>
                <?php } ?></td>
            </tr>
          </table>
        </div>
        <div id="tab-image">
          <table class="form">
            <tr>
              <td><?php echo $entry_logo; ?></td>
              <td>
              	<?php if(isset($restaurant_id)){?>
              	<div class="image"><img src="<?php echo $logo; ?>" alt="" id="thumb-logo" />
                  <input type="hidden" name="config_logo" value="<?php echo $config_logo; ?>" id="logo" />
                  <br />
                  <a onclick="image_upload('logo', 'logo', 'thumb-logo');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb-logo').attr('src', '<?php echo $no_image; ?>'); $('#logo').attr('value', '');"><?php echo $text_clear; ?></a></div>
                <?php } else {
                ?>
                	<span class="error">
                		<?php echo $warning_edit_mode; ?>
                	</span>
                <?php }?>
              </td>
            </tr>
            <tr>
              <td><?php echo $entry_icon; ?></td>
              <td>
              	<?php if(isset($restaurant_id)){?>
              	<div class="image"><img src="<?php echo $icon; ?>" alt="" id="thumb-icon" />
                  <input type="hidden" name="config_icon" value="<?php echo $config_icon; ?>" id="icon" />
                  <br />
                  <a onclick="image_upload('icon', 'icon','thumb-icon');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb-icon').attr('src', '<?php echo $no_image; ?>'); $('#icon').attr('value', '');"><?php echo $text_clear; ?></a></div>
                <?php } else {
                ?>
                	<span class="error">
                		<?php echo $warning_edit_mode; ?>
                	</span>
                <?php }?>
              </td>
            </tr>
            <tr>
              <td><?php echo $entry_image; ?></td>
              <td valign="top">
                <?php if(isset($restaurant_id)){?>
	              	<div class="image"><img src="<?php echo $thumb; ?>" alt="" id="thumb" />
	                <input type="hidden" name="image" value="<?php echo $image; ?>" id="restaurantimage" />
	                <br /><a onclick="image_upload('restaurantimage' , 'restaurant', 'thumb');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb').attr('src', '<?php echo $no_image; ?>'); $('#image').attr('value', '');"><?php echo $text_clear; ?></a></div>
                <?php } else {
                ?>
                	<span class="error">
                		<?php echo $warning_edit_mode; ?>
                	</span>
                <?php }?>
              </td>
            </tr>
            <tr>
              <td colspan="2">
		          <table id="images" class="list">
		            <thead>
		              <tr>
		                <td class="left" style="width:150px"><?php echo $entry_image_more; ?></td>
		                <td class="right"><?php echo $entry_sort_order; ?></td>
		                <td style="width:150px"></td>
		              </tr>
		            </thead>
		            <?php $image_row = 0; ?>
		            <?php foreach ($more_images as $more_image) { ?>
		            <tbody id="image-row<?php echo $image_row; ?>">
		              <tr>
		                <td class="left"><div class="image"><img src="<?php echo $more_image['thumb']; ?>" alt="" id="thumb<?php echo $image_row; ?>" />
		                    <input type="hidden" name="more_image[<?php echo $image_row; ?>][image]" value="<?php echo $more_image['image']; ?>" id="image<?php echo $image_row; ?>" />
		                    <br />
		                    <a onclick="image_upload('image<?php echo $image_row; ?>', 'restaurant', 'thumb<?php echo $image_row; ?>');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb<?php echo $image_row; ?>').attr('src', '<?php echo $no_image; ?>'); $('#image<?php echo $image_row; ?>').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
		                <td class="right"><input type="text" name="more_image[<?php echo $image_row; ?>][sort_order]" value="<?php echo $more_image['sort_order']; ?>" size="2" /></td>
		                <td class="center"><a onclick="$('#image-row<?php echo $image_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
		              </tr>
		            </tbody>
		            <?php $image_row++; ?>
		            <?php } ?>
		            <tfoot>
		              <tr>
		                <td colspan="2"></td>
		                <td class="center"><a onclick="addImage();" class="button"><?php echo $button_add_image; ?></a></td>
		              </tr>
		            </tfoot>
		          </table>              
              </td>
            </tr>
          </table>
        </div>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
$('#template').load('index.php?route=restaurant/autocomplete/template&token=<?php echo $token; ?>&template_id=' + encodeURIComponent($('select[name=\'config_template\']').attr('value')));
//--></script> 
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script> 
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', {
	filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>
//--></script> 
<script type="text/javascript"><!--
function image_upload(field, folder,thumb) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&restaurant_id=<?php echo isset($this->request->get['restaurant_id'])?$this->request->get['restaurant_id']:$this->restaurant->getRestaurantId();?>&folder=' + encodeURIComponent(folder) + '&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).val()),
					dataType: 'text',
					success: function(data) {
						$('#' + thumb).replaceWith('<img src="' + data + '" alt="" id="' + thumb + '" />');
					}
				});
			}
		},	
		bgiframe: false,
		width: 800,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script> 
<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;
var address_row = <?php echo $address_row; ?>;

function addImage() {
    html  = '<tbody id="image-row' + image_row + '">';
	html += '  <tr>';
	html += '    <td class="left"><div class="image"><img src="<?php echo $no_image; ?>" alt="" id="thumb' + image_row + '" /><input type="hidden" name="more_image[' + image_row + '][image]" value="" id="image' + image_row + '" /><br /><a onclick="image_upload(\'image' + image_row + '\',\'restaurant\', \'thumb' + image_row + '\');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$(\'#thumb' + image_row + '\').attr(\'src\', \'<?php echo $no_image; ?>\'); $(\'#image' + image_row + '\').attr(\'value\', \'\');"><?php echo $text_clear; ?></a></div></td>';
	html += '    <td class="right"><input type="text" name="more_image[' + image_row + '][sort_order]" value="" /></td>';
	html += '    <td class="center"><a onclick="$(\'#image-row' + image_row  + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
	html += '  </tr>';
	html += '</tbody>';
	
	$('#images tfoot').before(html);
	
	image_row++;
}

function addAddress(){
    html  = '<tbody id="address-row' + address_row + '">';
    html  += '<tr>';
    html  += '<td>';
    html  += '	<select name="addresses[' + address_row + '][country_id]" id="country_id' + address_row + '" onchange="$(\'#city_id' + address_row + '\').load(\'index.php?route=restaurant/autocomplete/city&token=<?php echo $token; ?>&country_id=\' + this.value);">';
          		<?php foreach ($countries as $country) { ?>
    html  += '       <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>';
          		<?php } ?>
    html  += '    </select>';
    html  += '</td>';
    html  += '<td>';
    html  += '	<select name="addresses[' + address_row + '][city_id]" id="city_id' + address_row + '" onchange="$(\'#district_id' + address_row + '\').load(\'index.php?route=restaurant/autocomplete/district&token=<?php echo $token; ?>&city_id=\' + this.value);">';
    html  += '	</select>';
    html  += '</td>';
    html  += '<td>';
    html  += '	<select name="addresses[' + address_row + '][district_id]" id="district_id' + address_row + '">';
    html  += '  </select>';
    html  += '</td>';
    html  += '<td>';
    html  += '	<textarea name="addresses[' + address_row + '][address]" cols="60" rows="5"></textarea>';
    html  += '</td>';
    html  += '<td class="center"><a onclick="$(\'#address-row' + address_row + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
    html  += '</tr>';
	html  += '</tbody>';

	$('#addresses tfoot').before(html);

	// Load default citys
	$('#city_id' + address_row).load('index.php?route=restaurant/autocomplete/city&token=<?php echo $token; ?>&country_id=<?php echo $countries[0]['country_id'];?>', function() {
		$('#district_id' + $(this).attr('id').replace('city_id','')).load('index.php?route=restaurant/autocomplete/district&token=<?php echo $token; ?>&city_id=' + $(this).val());
	});
	
	address_row++;	
}
//--></script> 
<script type="text/javascript"><!--
$('#tabs a').tabs();
$('#languages a').tabs(); 
$('#vtab-option a').tabs();
//--></script> 
<?php echo $footer; ?>